<?php


class ArticleCategorysTable extends Doctrine_Table
{
    
    public static function getInstance()
    {
        return Doctrine_Core::getTable('ArticleCategorys');
    }

    public function getTopArticleCategorys($select = false)
    {
        $categorys_query = $this->createQuery()->select('id,name');
        $categorys = array();
        if(!$select)
        {
            $categorys = array(
                               0 => '顶级分类'
                            );
            $article_categorys = $categorys_query->where('parent_id = ?',0);
        }
        $article_categorys = $categorys_query->execute();
        if( 0 < $article_categorys->count() )
        {
            foreach( $article_categorys as $article_category )
            {
                $categorys[$article_category->getId()] = $article_category->getName();
            }
        }
        return $categorys;
    }

}